﻿
Namespace Negocios

    Public Class Champions

#Region "Variáveis"


#End Region

#Region "Propriedades"


#End Region

#Region "Construtores"


#End Region

#Region "Funções privadas"

        Private Function ConverteDataTableEmLista(ByVal dtRetorno As DataTable) As List(Of Objetos.Champion)

            Try

                Dim lisChampions As New List(Of Objetos.Champion)
                Dim objChampion As Objetos.Champion

                For Each drLinha As DataRow In dtRetorno.Rows

                    objChampion = New Objetos.Champion

                    With objChampion

                        .Codigo = Convert.ToInt32(drLinha("Codigo"))
                        .Nome = Convert.ToString(drLinha("Nome"))
                        .HP_Base = Convert.ToDecimal(drLinha("Health"))
                        .HP_Base_Level = Convert.ToDecimal(drLinha("Health_level"))
                        .HP_Regen_Base = Convert.ToDecimal(drLinha("Health_regen"))
                        .HP_Regen_Base_Level = Convert.ToDecimal(drLinha("Health_regen_level"))
                        .Tipo_de_recurso = Convert.ToInt32(drLinha("Resource_type"))
                        .Recurso_Base = Convert.ToDecimal(drLinha("Resource"))
                        .Recurso_Base_Level = Convert.ToDecimal(drLinha("Resource_level"))
                        .Recurso_Regen_Base = Convert.ToDecimal(drLinha("Resource_regen"))
                        .Recurso_Regen_Base_Level = Convert.ToDecimal(drLinha("Resource_regen_level"))
                        .Range = Convert.ToDecimal(drLinha("Range"))
                        .Attack_Damage_Base = Convert.ToDecimal(drLinha("Attack_damage"))
                        .Attack_Damage_Base_Level = Convert.ToDecimal(drLinha("Attack_damage_level"))
                        .Attack_Speed_Base = Convert.ToDecimal(drLinha("Attack_speed"))
                        .Attack_Speed_Base_Level_Perc = Convert.ToDecimal(drLinha("Attack_speed_level"))
                        .Armor_Base = Convert.ToDecimal(drLinha("Armor"))
                        .Armor_Base_Level = Convert.ToDecimal(drLinha("Armor_level"))
                        .Magic_Resist_Base = Convert.ToDecimal(drLinha("Magic_resist"))
                        .Magic_Resist_Base_Level = Convert.ToDecimal(drLinha("Magic_resist_level"))
                        .Movement_Speed_Base = Convert.ToDecimal(drLinha("Moviment_speed"))
                        .Ability_Power_Base = Convert.ToDecimal(drLinha("Ability_power"))
                        .Ability_Power_Base_Level = Convert.ToDecimal(drLinha("Ability_power_level"))

                    End With

                    lisChampions.Add(objChampion)

                Next

                Return lisChampions

            Catch ex As Exception
                Throw
            End Try

        End Function

#End Region

#Region "Funções Friend"


#End Region

#Region "Funções públicas"

        Public Function RetornarListaChampions() As List(Of Objetos.Champion)

            Try

                Dim objConexao As New LoLLibrary.Dados.Conexao
                Return ConverteDataTableEmLista(objConexao.RetornarDataTable("Select * from Champions Order by Nome asc"))

            Catch ex As Exception
                Throw
            End Try


        End Function

        Public Shared Function TrataNomeChampion(ByVal strNomeChampion As String) As String

            Return strNomeChampion.Replace(" ", String.Empty).Replace("'", String.Empty).Replace(".", String.Empty)

        End Function

#End Region

    End Class

End Namespace